<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<input type="text" value="100" id="input1">
		<button id="btn1" onclick="test1()">开启超时</button>
		<button id="btn2" onclick="test2()">关闭超时</button>
		<script type="text/javascript">
			var t;
			function test1()
			{
				t=setTimeout(change,input1.value)
			}
			function test2()
			{
				clearTimeout(t);
			}
			function change()
			{
				var r=Math.floor(Math.random()*256);
				var g=Math.floor(Math.random()*256);
				var b=Math.floor(Math.random()*256);
				document.body.style.background="rgb("+r+","+g+","+b+")";
				
				t=setTimeout(change,input1.value)
			}
		</script>
	</body>
</html>
